﻿<UserControl x:Class="CredentialsManager.Views.ResetPasswordView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             Height="250" Width="300">
    <UserControl.Resources>
        <Style x:Key="QandAStyle" TargetType="{x:Type FrameworkElement}">
            <Setter Property="Visibility" Value="Collapsed" />            
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding RequiresQuestionAndAnswer}" Value="True" />
                        <Condition Binding="{Binding IsPasswordReset}" Value="False" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="Visibility" Value="Visible" />
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <StackPanel Margin="5">
        <WrapPanel Margin="0, 10, 0, 10">
            <TextBlock>User:</TextBlock>
            <TextBlock Text="{Binding UserName}" />
        </WrapPanel>
        <StackPanel Margin="0, 10, 0, 10" Style="{StaticResource QandAStyle}">
            <TextBlock Text="{Binding SecurityQuestion}" TextWrapping="WrapWithOverflow" Margin="0, 10, 0, 10" />
            <TextBox Text="{Binding SecurityAnswer, UpdateSourceTrigger=PropertyChanged}" />
        </StackPanel>
        <Grid Margin="0, 10, 0, 10">
            <Grid.Style>
                <Style TargetType="{x:Type Grid}">
                    <Setter Property="Visibility" Value="Collapsed" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding IsPasswordReset}" Value="True">
                            <Setter Property="Visibility" Value="Visible" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>                       
            </Grid.Style>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <TextBlock Margin="0,0,10,0" Grid.Column="0" Grid.Row="0">New password:</TextBlock>
            <TextBox IsReadOnly="True" Text="{Binding Password}" Grid.Column="1" Grid.Row="0" BorderThickness="0" />
            <TextBlock Text="The password has been sent to the clipboard" Grid.ColumnSpan="2" Grid.Row="1" Grid.Column="0" />
        </Grid>       
        <WrapPanel>
            <Button Command="{Binding ResetCommand}" Content="Reset" Margin="5" Padding="5"
                    Style="{StaticResource QandAStyle}" IsEnabled="{Binding IsValid}" />
            <Button Command="{Binding CloseCommand}" Margin="5" Padding="5">Close</Button>
        </WrapPanel>
    </StackPanel>
</UserControl>
